<template>
  <div>
    <ul class="lesson_mainlist" v-if="haveorno == 1">
      <li v-for="(item,key) in mainlist" :key="key" @click="godetail(item.vid,item.data_type)">
          <span class="lesson_mainlist_pic">
            <img :src="item.picture" alt="" mode="widthFix">
            <p v-if="item.data_type == 2">专栏</p>
            <p v-if="item.data_type == 1">视频</p>
            <p v-if="item.data_type == 3">图文</p>
          </span>
        <span class="lesson_mainlist_txt">
          <span class="title">{{item.title}}</span>
          <span class="text">{{item.detail}}</span>
          <span class="text speed" v-if="buyorlearn == 0">购买时间: {{item.play_time}}</span>
          <span class="text speed" v-if="buyorlearn == 1">上次学习时间: {{item.play_time}}</span>
        </span>
      </li>
    </ul>

    <div class="noangylesson" v-if="haveorno == 0">
      <img src="./../../../assets/img/noanylesson.png" alt="">
      <p>你还没有任何课程</p>
      <span>去逛逛</span>
    </div>
  </div>
</template>

<script>
export default {
  name: 'LessonList',
  props: {
    mainlist: {
    },
    buyorlearn:{
      type: String | Number ,
      default:""
    }
  },
  data () {
    return {
      haveorno: 1
    }
  },
  methods: {
    godetail (vid, type) {
      if (type == 2) {
        this.$router.push({ name: 'detailofboom', path: '/detailofboom', query: { vid: vid } })
      }
      if (type == 1) {
        this.$router.push({ name: 'detailofvedio', path: '/detailofvedio', query: { vid: vid } })
      }
      if (type == 3) {
        this.$router.push({ name: 'detailofpic', path: '/detailofpic', query: { vid: vid } })
      }
    }
  },
  computed: {
    recommendList () {
      return this.mainlist
    }
  }
}

</script>

<style  lang="less" scoped>
  .lesson_mainlist li{
    width: 100%;
    height: 7.5rem;
    border-bottom: 1px solid #f5efef;
    overflow: hidden;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    background: white;
    .lesson_mainlist_pic{
      position: relative;
      width: 40%;
      height: 5.65rem;
      display: flex;
      justify-content: center;
      margin-top: 1rem;
      margin-left: 1rem;
      img{
        width: 100%;
        border-radius:0.5rem ;
      }
      p{
        position: absolute;
        bottom: 0;
        width: 100%;
        text-align: right;
        font-size: 14px;
        background: linear-gradient(#908080, black);
        opacity: 0.3;
        color: white;
      }
    }
    .lesson_mainlist_txt{
      margin-top: 1rem;
      margin-right: 1rem;
      margin-left: 0.7rem;
      width: 60%;
      height: 5.65rem;
      display: flex;
      flex-direction: column;
      justify-content: space-around;
      overflow: hidden;
      .title{
        width: 100%;
        overflow: hidden;
        text-overflow:ellipsis;
        white-space:nowrap;
        font-size: 15px;
        font-weight: 600;
      }
      .text{
        width: 100%;
        font-size: 12px;
        color: #b8b8b8;
        overflow: hidden;
        margin-top: 25px;
        overflow:hidden;
        text-overflow:ellipsis;
        white-space:nowrap
      }
      .speed{
        color: #53d68d;
      }
    }
  }
  .noangylesson{
    width: 100%;
    height: 590px;
    background: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    img{
      width: 200px;
      height: 130px;
      margin-top: -250px;
    }
    p{
      font-size: 14px;
      color: #b8b8b8;
      margin-top: 20px;
      margin-bottom: 20px;
    }
    span{
      width: 100px;
      height: 35px;
      text-align: center;
      line-height: 35px;
      font-size: 14px;
      border-radius: 4px;
      background: #187a72;
      color: white;
    }
  }
</style>
